import logging

import allure
from selenium.webdriver.common.by import By

from ding.LitemallPrac.page_objects.base_page import BasePage


class LoginPage(BasePage):

    _INPUT_USENAME  = (By.XPATH ,"//*[@id='app']/div/form/div[2]/div/div/input")
    _INPUT_PASSWORD = (By.XPATH,"//*[@id='app']/div/form/div[3]/div/div/input")       #//input[@name = 'password']
    _BUTTON_LOGIN   = (By.CSS_SELECTOR,"button.el-button")

    #登录-
    with allure.step("登录"):
        def login(self):
            # 输入用户名
            logging.info("输入用户名")
            self.do_send_keys("admin123", *self._INPUT_USENAME)
            # 输入密码
            logging.info("输入密码")
            self.do_send_keys("admin123", *self._INPUT_PASSWORD)
            # 点击登录按钮
            logging.info("点击“登录”按钮")
            self.do_click(*self._BUTTON_LOGIN)




            from ding.LitemallPrac.page_objects2.home_page2 import HomePage
            return HomePage(self.driver)



        #return CommentPage(self.driver)



